class_name PopupText
extends Control

#region 属性
@export var rich_text:RichTextLabel
@export var rise_height:float = 15
@export var scale_up_duration:float = 0.3
@export var scale_up:Vector2 = Vector2(0.5,0.5)
@export var scale_down_duration:float = 0.2
@export var scale_down:Vector2 = Vector2(0.2,0.2)
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func init_text(text):
	self.rich_text.text = text
	_popup()
#endregion
#region 私有方法
func _popup():
	scale = Vector2.ZERO
	
	create_tween().tween_property(self,"global_position:y",global_position.y - rise_height,scale_up_duration+scale_down_duration)

	var tween0:Tween = create_tween()
	tween0.tween_interval(scale_up_duration)
	tween0.tween_property(rich_text,"theme_override_colors/default_color:a",0,scale_up_duration+scale_down_duration).set_ease(Tween.EASE_IN)
	
	var tween1:Tween = create_tween()
	tween1.tween_property(self,"scale",scale_up,scale_up_duration).set_ease(Tween.EASE_IN)
	tween1.tween_property(self,"scale",scale_down,scale_down_duration).set_ease(Tween.EASE_OUT)
	tween1.tween_callback(func ():
		queue_free()
		)
#endregion
#region 生命周期函数
#endregion
